package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author stone
 * @date 2022/07/12 09:42
 */
@RestController
@RequestMapping("account")
public class AccountController {

    @Autowired
    AccountService accountService;

    //localhost:8080/account/transfer?fromId=1&destId=2&money=1000
    @RequestMapping("transfer")
    public BaseRespVo transfer(HttpServletRequest request) {
        int fromId = Integer.valueOf(request.getParameter("fromId"));
        int destId = Integer.valueOf(request.getParameter("destId"));
        int money = Integer.valueOf(request.getParameter("money"));
        accountService.transfer(fromId, destId, money);
        return BaseRespVo.ok("zhuanzhang chenggong");
    }

}
